#!/usr/bin/env python
# -*- encoding: utf-8 -*-
# Project: spd-sxmcc
"""
@author: lyndon
@time Created on 2018/9/11 13:08
@desc
"""

from abc import ABC, abstractmethod
import random


class Talker(ABC):
    @abstractmethod
    def talker(self):
        pass


class Knigger(Talker):
    def talker(self):
        print("Ni!")


k = Knigger()

k.talker()

print(issubclass(Knigger, Talker))
print(isinstance(k, Knigger))  # True
print(isinstance(k, Talker))  # True
print(isinstance(k, ABC))  # True
print(hasattr(k, 'talk'))  # False
print(hasattr(k, 'talker'))  # True

print(callable(getattr(k, 'talk', None)))  # False
print(callable(getattr(k, 'talker', None)))  # False

setattr(k, 'name', 'Mr. Hu')
try:
    print(k.name)
except Exception:
    print("Error! k not have name.")


lst = [i for i in range(1, 5)]
print(type(lst))
print(lst)
print(random.choice(lst))
